package jee.boot.common.basic.interceptor;

import com.google.common.collect.Lists;
import jee.boot.common.basic.interceptor.impl.DefaultPreInsertInterceptor;
import jee.boot.common.basic.interceptor.impl.DefaultPreQueryInterceptor;
import jee.boot.common.basic.interceptor.impl.DefaultPreUpdateInterceptor;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 前置操作注册器
 */
@Component
public class InterceptorRegister {
    private List<PreInsertInterceptor> preInsertInterceptorList= Lists.newArrayList();
    private List<PreUpdateInterceptor> preUpdateInterceptorList= Lists.newArrayList();
    private List<PreQueryInterceptor> preQueryInterceptorList= Lists.newArrayList();
    private List<PostInsertInterceptor> postInsertInterceptorList= Lists.newArrayList();
    private List<PostUpdateInterceptor> postUpdateInterceptorList= Lists.newArrayList();
    private List<PostQueryInterceptor> postQueryInterceptorList= Lists.newArrayList();

    public InterceptorRegister() {
        addPreInsertInterceptor(new DefaultPreInsertInterceptor());
        addPreQueryInterceptor(new DefaultPreQueryInterceptor());
        addPreUpdateInterceptor(new DefaultPreUpdateInterceptor());
    }

    public void addPreInsertInterceptor(PreInsertInterceptor preInsertInterceptor) {
        this.preInsertInterceptorList.add(preInsertInterceptor);
    }

    public void addPreUpdateInterceptor(PreUpdateInterceptor preUpdateInterceptor) {
        this.preUpdateInterceptorList.add(preUpdateInterceptor);
    }

    public void addPreQueryInterceptor(PreQueryInterceptor preQueryInterceptor) {
        this.preQueryInterceptorList.add(preQueryInterceptor);
    }
    public void addPostInsertInterceptor(PostInsertInterceptor postInsertInterceptor) {
        this.postInsertInterceptorList.add(postInsertInterceptor);
    }

    public void addPostUpdateInterceptor(PostUpdateInterceptor postUpdateInterceptor) {
        this.postUpdateInterceptorList.add(postUpdateInterceptor);
    }

    public void addPostQueryInterceptor(PostQueryInterceptor preQueryInterceptor) {
        this.postQueryInterceptorList.add(preQueryInterceptor);
    }
    public List<PreInsertInterceptor> getPreInsertInterceptorList() {
        return preInsertInterceptorList;
    }

    public void setPreInsertInterceptorList(List<PreInsertInterceptor> preInsertInterceptorList) {
        this.preInsertInterceptorList = preInsertInterceptorList;
    }

    public List<PreUpdateInterceptor> getPreUpdateInterceptorList() {
        return preUpdateInterceptorList;
    }

    public void setPreUpdateInterceptorList(List<PreUpdateInterceptor> preUpdateInterceptorList) {
        this.preUpdateInterceptorList = preUpdateInterceptorList;
    }

    public List<PreQueryInterceptor> getPreQueryInterceptorList() {
        return preQueryInterceptorList;
    }

    public void setPreQueryInterceptorList(List<PreQueryInterceptor> preQueryInterceptorList) {
        this.preQueryInterceptorList = preQueryInterceptorList;
    }

    public List<PostInsertInterceptor> getPostInsertInterceptorList() {
        return postInsertInterceptorList;
    }

    public void setPostInsertInterceptorList(List<PostInsertInterceptor> postInsertInterceptorList) {
        this.postInsertInterceptorList = postInsertInterceptorList;
    }

    public List<PostUpdateInterceptor> getPostUpdateInterceptorList() {
        return postUpdateInterceptorList;
    }

    public void setPostUpdateInterceptorList(List<PostUpdateInterceptor> postUpdateInterceptorList) {
        this.postUpdateInterceptorList = postUpdateInterceptorList;
    }

    public List<PostQueryInterceptor> getPostQueryInterceptorList() {
        return postQueryInterceptorList;
    }

    public void setPostQueryInterceptorList(List<PostQueryInterceptor> postQueryInterceptorList) {
        this.postQueryInterceptorList = postQueryInterceptorList;
    }
}
